import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lishuo
 * Date: 2023-04-18
 * Time: 23:49
 */
public class IOdemo6 {
    public static void main(String[] args) throws IOException {
        try (InputStream inputStream = new FileInputStream("test.txt")) {
            while (true) {
                // 读文件
                // read 一次返回的是一个字节. 但是此处的返回值类型是 int !!!
                // 因为 返回值要求是-1~255 所以尽量用大的类型表示，就用int
                int b = inputStream.read();
                if (b==-1) {
                    break;
                }
                System.out.printf("%x\n",b);
            }
        }
    }
}
